<!-- 薪资排行 -->
<template>
	<view class="page" v-if="my == 'true'">
		<u-navbar title="每日任务"></u-navbar>
		<view class="page-box">
			<block v-for="(task, index) in taskList" :key="index">
				<block v-if="index < 3">
					<view class="card-box" v-if="'rate' == task.taskType">
						<view class="title">{{task.title}}</view>
						<view class="desc">{{task.taskDesc}}</view>
						<view>
							<u-button @click="pingjia(task)" type="success">去评价</u-button>
						</view>
					</view>
					<view class="card-box" v-if="'sign' == task.taskType">
						<view class="title">{{task.title}}</view>
						<view class="desc">{{task.taskDesc}}</view>
						<view>
							<u-button @click="doSign(task)" type="success">去签到</u-button>
						</view>
					</view>
					<view class="card-box" v-if="'share' == task.taskType">
						<view class="title">{{task.title}}</view>
						<view class="desc">{{task.taskDesc}}</view>
						<view>
							<u-button open-type="share" type="success">去邀请</u-button>
						</view>
					</view>
					<view class="card-box" v-if="'service' == task.taskType">
						<view class="title">{{task.title}}</view>
						<view class="desc">{{task.taskDesc}}</view>
						<view>
							<u-button @click="doOrder" type="primary">去下单</u-button>
						</view>
					</view>
				</block>
			</block>
			
		</view>
		
		<qrcode-popup :msg="msg"></qrcode-popup>
			
	</view>
</template>

<script>
	import qrcodePopup from "@/components/qrcode-popup/qrcode-popup";
	export default {
		components: {
			qrcodePopup,
		},
		data() {
			return {
				userId: 0,
				my: 'false',
				msg: '记得关注服务号避免下次找不到',
				taskList: [],
			}
		},
		onLoad(option) {
			this.my = option.my;
			this.userId = uni.getStorageSync("userId");
			this.getTaskList();
		},
		onShareAppMessage(res) {
			return {
				title: '送你一个对象，快来「处CP」吧！',
				path: '/pages/index?shareUserId='+this.userId,
				imageUrl: 'http://rbtnet.oss-cn-hangzhou.aliyuncs.com/test/20220914/58242695c2a8421b892eced5f1bd3b15.jpeg',
			};
		},
		onShareTimeline() {
			return {
				title: '送你一个对象，快来「处CP」吧！',
				path: '/pages/index?shareUserId='+this.userId,
				imageUrl: 'http://rbtnet.oss-cn-hangzhou.aliyuncs.com/test/20220914/58242695c2a8421b892eced5f1bd3b15.jpeg',
			};
		},
		methods: {
			doOrder() {
				this.$store.commit('setQr', true);
			},
			getTaskList() {
				this.$u.get('/wq/task/list').then(res => {
					this.taskList = res.data;
				});
			},
			sumitTask(id) {
				this.$u.post('/wq/task/ok',{
					id: id,
				}).then(res => {
					this.taskList = res.data;
				});
			},
			pingjia(e) {
				var that = this;
				var plugin = requirePlugin("wxacommentplugin");
				plugin.openComment({
				  success: (res)=>{
					if(res.errCode == 0){
						that.sumitTask(e.id);
					}
				  },
				  fail: (res) =>{
				    console.log('plugin.openComment fail', res)
				  }
				})
			},
			doSign(e) {
				this.judgeLogin(() => {
					this.sumitTask(e.id);
				});
			},
			
		},
	}
</script>

<style lang="scss" scoped>
	.page {
		background-color: #f9f8f8;
		position: absolute;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
	}
	
	.page-box {
		background-color: #fff;
		margin: 10px;
		border-radius: 10px;
		padding: 15px;
		padding-bottom: 0;
	}
	
	.card-box {
		padding-bottom: 15px;
		
		.title {
			font-size: 28rpx;
			font-weight: bolder;
		}
		
		.desc {
			font-size: 28rpx;
			margin: 10px 0;
		}
	}
	
	.slot-wrap {
		padding-left: 10px;
	}
	.form-box {
		padding: 15px;
	}
	.avatar {
		position: relative;
	}
	.avatar-box {
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #fff;
		border-radius: 10px;
	}
	.avatar-icon {
		position: absolute;
		bottom: 20rpx;
		right: 0px;
		background: #303133;
		padding: 10rpx 12rpx;
		border-radius: 100px;
	}
	.form-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 15px 0;
	}
	.form-label {
		font-size: 32rpx;
		width: 100px;
	}
	.form-text {
		font-size: 30rpx;
		color: #817e7e;
		display: flex;
		justify-content: flex-end;
		flex: 1;
		line-height: 15px;
	}
	.form-set {
		font-size: 30rpx;
		color: #929292bd;
		display: flex;
		justify-content: flex-end;
		flex: 1;
		line-height: 15px;
	}
	.mh {
		min-height: 100px;
	}
	.form-page {
		padding: 15px;
		background-color: #fff;
		margin-top: 15px;
		border-radius: 10px;
	}
	.photo-box {
		background-color: #fff;
		border-radius: 10px;
		padding: 15px;
		margin-bottom: 15px;
	}
	.card-title {
		font-size: 32rpx;
		display: flex;
		align-items: center;
		margin-bottom: 15px;
	}
	.card-title-tip {
		margin-left: 5px;
		font-size: 28rpx;
		color: #eca419;
		display: flex;
		align-items: center;
	}
	.tip-text {
		font-size: 24rpx;
	}
	.id-card-box {
		display: flex;
	}
	.slot-btn {
		margin-right: 20rpx;
	}
	.slot-btn image {
		width: 250rpx;
		height: 150rpx;
	}
	.id-card-btn {
		background-color: #5581ff;
		display: flex;
		justify-content: center;
		padding: 5px;
		color: #fff;
		border-bottom-left-radius: 10px;
		border-bottom-right-radius: 10px;
	}
	.id-card-bg {
		background-color: #f4f8fe;
		padding: 10px;
		border-top-left-radius: 10px;
		border-top-right-radius: 10px;
	}
	.step-box {
		padding-top: 15px;
	}
	.content {
		padding: 15px;
	}
	.age-label {
		font-size: 14px;
		margin-bottom: 15px;
	}
	.btn-box {
		padding: 0 15px;
		padding-bottom: 30px;
	}
	.pay-tip {
		padding-bottom: 15px;
	}
	.slot-content {
		padding: 10px 20px;
		font-size: 30rpx;
		border-bottom: 1px solid rgb(214, 215, 217);
	}
</style>
